import { stringify } from 'qs';
import request from '../utils/request';
import host from './host';
import {getAuthToken} from '../utils/authority';

// 提交文章,添加或更新
export async function fakeSubmitArticle(params) {
    const newParams = {...params,...{authToken:getAuthToken()}}
    return request(`${host.host}/bearadmin/article/update`, {
        method: 'POST',
        body: newParams,
    });
}

// 获取文章
export async function queryArticle(id) {
    return request(`${host.host}/bearadmin/article/${id}?authToken=${getAuthToken()}`);
}

export async function queryArticleList(params) {
    return request(`${host.host}/bearadmin/article?${stringify(params)}&authToken=${getAuthToken()}`);
}

export async function queryComment(params){
    return request(`${host.host}/bearadmin/article/comment?${stringify(params)}&authToken=${getAuthToken()}`);
}

export async function subCheck(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/subcheck`, {
    method: 'POST',
    body: newParams,
  });
}

export async function check(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/check`, {
    method: 'POST',
    body: newParams,
  });
}

export async function pubArticle(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/pub`, {
    method: 'POST',
    body: newParams,
  });
}

export async function cancelPubArticle(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/cancelpub`, {
    method: 'POST',
    body: newParams,
  });
}


export async function reply(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/comment/reply`, {
    method: 'POST',
    body: newParams,
  });
}

export async function status(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/comment/status`, {
    method: 'POST',
    body: newParams,
  });
}

export async function deleteReply(params) {
  const newParams = {...params,...{authToken:getAuthToken()}};
  return request(`${host.host}/bearadmin/article/comment/delete/reply`, {
    method: 'POST',
    body: newParams,
  });
}
